Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

fix(vite): close vite watcher before building#5875

Merged
pi0 merged 2 commits intomainfrom
perf/build-watch
Jul 13, 2022
Merged

fix(vite): close vite watcher before building#5875
pi0 merged 2 commits intomainfrom
perf/build-watch

Conversation

@danielroe
Copy link
Copy Markdown
Member

🔗 Linked issue

resolves nuxt/nuxt#14246

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

We continue watching files during the vite build process, and if (due to a race condition) tsconfig.json is written after vite build starts it can trigger a vite error from the esbuild plugin.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroe danielroe added bug Something isn't working vite labels Jul 13, 2022
@danielroe danielroe requested a review from antfu July 13, 2022 12:03
@danielroe danielroe self-assigned this Jul 13, 2022
@netlify
Copy link
Copy Markdown

netlify Bot commented Jul 13, 2022

Deploy Preview for nuxt3-docs canceled.

Name Link
🔨 Latest commit b058b2d
🔍 Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/62cebe0e2a5cad000838378e

Copy link
Copy Markdown
Member

@atinux atinux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you ❤️

Comment thread packages/vite/src/vite.ts
ctx.config.plugins.push({
name: 'nuxt:close-vite-watcher',
configureServer (server) {
return server?.watcher?.close()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a good workaround but I expect to track this issue. watcher starting for production build is a little bit strange

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, it seems strange.

what do you think @antfu? should we raise upstream at vite?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we raise upstream at vite?

Sure if we could provide a reproduction out-side of Nuxt.

Ideally the configureServer shouldn't even be called in build, or we might accidentally have a vite dev server on build?

@pi0 pi0 merged commit 3ad12b5 into main Jul 13, 2022
@pi0 pi0 deleted the perf/build-watch branch July 13, 2022 12:44
@pi0 pi0 mentioned this pull request Jul 13, 2022
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.x bug Something isn't working vite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build error: ERROR [unhandledRejection] Cannot read properties of null (reading 'config')

4 participants